/**
 * 
 */
package boundary.components;

import java.awt.Container;

import javax.swing.JFileChooser;
import javax.swing.filechooser.FileFilter;

import calculator.ImageFilter;
import calculator.QuadTreeFilter;

/**
 * @author davide
 *
 */
public abstract class MyJFileChooser extends JFileChooser
{
    private static final long serialVersionUID = 5296384815759507457L;
    
    protected MyJFileChooser(int i)
    {
	this.setFileView(new ImageFileView());
	this.setFilters(i, new ImageFilter(), new QuadTreeFilter());
    }

    protected void setFilters(int nItem, FileFilter... fileFilters)
    {
	for (FileFilter item : fileFilters) {
	    this.addChoosableFileFilter(item);
	}
	
	this.setFileFilter(fileFilters[nItem]);
    }
    
    public abstract boolean isValidSelection(Container parent);
}
